<template>
	<view style="height: 18%; width: 100%; opacity: 0;">
	  这是隐藏的文字,嘿嘿嘿
	</view>
	
	<view class="homeLayout ">
		<customnavbar/>
		<view class="banner">
			<swiper indicator-dots indicator-active-color="#ffffff" indicator-color="rgba(255,255,255,0.5)" autoplay="">
				<swiper-item v-for="item in bannerList" :key = "item._id">
					<image :src="item.picurl" mode="aspectFill"></image>
				</swiper-item>
				
			</swiper>
		</view>
		<view class="notice">
			<view class="left">
				<uni-icons type="sound-filled" size = '20' color="#28b389"></uni-icons>
				<text class="text">公告</text>
			</view>
			<view class="center">
				<swiper vertical autoplay = "" interval="1000" duration="100"  >
					<swiper-item v-for="index in list_index_picurl">
						<view class="swiper-item">{{index.value}}</view>
					</swiper-item>
				</swiper>
				
			</view>
			<view class="right">
				<uni-icons type="right" size = '18' color="#333"></uni-icons>
			</view>
		</view>
		<ProgressLine></progressLine>
		<view class="select">
			<common-title>
				<template #name>每日推荐</template>
				<template #custom>
				<view class="date">
					<uni-icons type="calendar" size = '30' color = '#28b839'></uni-icons>
					<uni-dateformat :date="Date.now()" format="dd日" />
				</view> 
				</template>
			</common-title>
			<view class="content">
				<scroll-view scroll-x>
					<view class="box" v-for="index in list_index_picurl" >
						<image :src="index.picurl" mode="aspectFill"></image>
					</view>
				</scroll-view>
			</view>
		</view>
		<view class="theme">
			<common-title>
				<template #name>
					专题精选
				</template>
				<template #custom>
					<navigator url="" class="more">More+</navigator>
				</template>
			</common-title>
			<view class="content">
				<theme-title v-for="item in classifyList" :key="item._id"
				:item = "item">	
				</theme-title>
				<theme-title :isMore = "true">
				</theme-title>
			</view>
		</view>
	</view>
	
	
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from "@dcloudio/uni-app" // ✅ 加上这一行
import { apiGetBanner, apiGetRandomDay, apiGetNotice, apiGetClassify } from '/api/apis.js'
import{ apiGetClassify_ctt ,apiGetClassList_ctt } from '/api/api_ctt.js'
import {onShareAppMessage, onShareTimeline} from "@dcloudio/uni-app"
import customnavbar from "@/components/custom-nav-bar/customnavbar.vue"
import ProgressLine from '@/components/progress-line/progress-line.vue'



onLoad(() => {
  const user = uni.getStorageSync('userInfo')
  if (!user) {
    uni.reLaunch({ url: '/pages/login/login' })
  }
})





	const bannerList = ref([]);
	const randomList = ref([]);
	const noticeList = ref([]);
	const classifyList = ref([]);
	
	const list_index = ref([]);
	const list_index_picurl = ref([]);
	
	const newWallDeatil_index = ref([]);
	
	const getBanner = async () => {
		 let res = await uni.request({
		 	url:"https://xrqr0h0x1w.gzg.sealos.run/get_bannerList"
		 })
		 bannerList.value = res.data.data
		 
	}
	
	// const getDayRandom = async() =>{
	// 	let res =await apiGetRandomDay();
	// 	randomList.value = res.data
		
	// }
	
	// const getNotice = async() =>{
	// 	let res =await apiGetNotice({select:true});
	// 	noticeList.value = res.data	
	//  }
	 
	
	 const getClassify_ctt = async () =>{
		 let res = await apiGetClassify_ctt({pageSize:8});
		   classifyList.value  = res.data  
	 }
	 
	 
	 
	 const getList = async () => {
	 	let res = await uni.request
		({
	 		url:"https://xrqr0h0x1w.gzg.sealos.run/get_list"
	 	})
	 		list_index.value = res.data.data
			list_index_picurl.value = res.data.data  	
	 }
	 
		 
	 onShareAppMessage((e) =>{
		return{
			title:"天天de壁纸",
			icon:"",
			path:"/pages/index/index",
		}
	 
	 })
	 
	 onShareTimeline(() => {
			 
		 return{
			 title:"tiantian的bizhi",
			 imageUrl:"https://cttxhy-1360132035.cos.ap-shanghai.myqcloud.com/ctt_logo/ctt_logo_1.jpg",
		 }
	 })
	
	getBanner();
	// getDayRandom();
	//getNotice();
	getClassify_ctt();
	//getwallList_ctt();
	getList()
</script>

<style lang = 'scss' scoped>
	.homeLayout{
		.banner{
			width: 750rpx;
			padding: 30rpx 0;
			swiper{
				width: 750rpx;
				height: 340rpx;
				swiper-item{
					width: 100%;
					height: 100%;
					padding: 0 30rpx;
					image{
						width: 100%;
						height: 100%;
						border-radius: 50rpx;
					}
				}
			}
			
			
		}
		.notice{
			width: 690rpx;
			height: 80rpx;
			line-height: 80rpx;
			background-color: #f9f9f9;
			margin: 0 auto;
			border-radius: 80rpx;
			display: flex;
			
			.left{
				width: 140rpx;
				:deep(){
					.uni-icons{
						color:$brand-theme-color !important;
					}
				}
				
			}
			.right{
				width: 70rpx;
				
			}
			.center{
				flex:1
			}
			
			
		}
		.select{
			padding-top: 50rpx;
			.date{
				color: $text-font-color-1;
				display: flex;
				align-items: center;
				.text{
					margin-left: 5rpx;
				}
			}
			.content{
				width: 720rpx;
				margin-left: 30rpx;
				margin-top: 30rpx;
				scroll-view{
					white-space: nowrap;
					.box{
						width: 200rpx;
						height: 430rpx;
						display: inline-block;
						margin-right:  15rpx;
						image{
							width: 100%;
							height: 100%;
							border-radius: 10rpx;
							
						}
					}
					.box:last-child{margin-right: 30rpx;}
				}
			}
		}
		.theme{
			padding: 0rpx;
			.more{
				font-size: 32rpx;
				color: #888;
			}
			.content{
				margin-top: 30rpx;
				padding: 0 30rpx;
				display: grid;
				gap:15rpx;
				grid-template-columns: repeat(3,1fr);
			}
		}
	}
	
</style>
